#@adminLayout()
#define main()
  <main class="app-content">
    <div class="app-title">
      <div>
        <h1><i class="fa fa-th-list"></i>敏感词管理</h1>
        <p>网站敏感词管理</p>
      </div>
      <ul class="app-breadcrumb breadcrumb">
        <li class="breadcrumb-item"><a href="/admin"><i class="fa fa-home fa-lg"></i>仪表盘</a></li>
        <li class="breadcrumb-item active"><a href="/admin/words">敏感词管理</a></li>
      </ul>
    </div>

	<div class="row">
		<div class="col-md-4">
          <div class="tile">
            <h3 class="tile-title">添加修改敏感词</h3>
            <div class="tile-body">
              <form method="post" action="">
              	<input type="hidden" name="id" id="id"/>
                <div class="form-group">
                  <label class="control-label">分类名称</label>
                  <input class="form-control" type="text" placeholder="请输入敏感词名称" name="word" id="word" required="required">
                </div>
                <div class="form-group">
                  <label class="control-label">是否启用</label>
                  <div class="form-check">
                    <label class="form-check-label">
                      <input class="form-check-input" type="radio" name="status" id="status" value="1" checked="checked"  required>是
                    </label>
                  </div>
                  <div class="form-check">
                    <label class="form-check-label">
                      <input class="form-check-input" type="radio" name="status" id="status"  value="0" required>否
                    </label>
                  </div>
                </div>
                <div class="form-group">
                  <label class="control-label">敏感词拼音</label>
                  <input class="form-control" type="text" placeholder="请输入敏感词拼音" name="word_pinyin" id="word_pinyin" required="required">
                </div>
              </form>
            </div>
            <div class="tile-footer">
              <a class="btn btn-primary" href="javascript:;" onclick="wordsSave();"><i class="fa fa-fw fa-lg fa-check-circle"></i>提交</a>
              <p><font id="errorInfo" color="red"></font></p>
            </div>
          </div>
        </div>
        
		<div class="col-md-8">
          <div class="tile">
            <h3 class="tile-title">敏感词列表</h3>
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>名称</th>
                  <th>是否启用</th>
                  <th>名称拼音</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              #for(x : wordsPage.getList())
                <tr>
                  <td>#(x.word)</td>
                  <td>
                 	<div class="toggle lg"><label>
                    	<input data-id="#(x.id)" type="checkbox" 
                    	#if(x.isWordsOk()) checked #end
                    	class="mgc-switch mgc-tiny" ><span class="button-indecator"></span></label>
                    </div>
                  </td>
                  <td>#(x.word_pinyin)</td>
                  <td>
                  	#permission("/admin/words/wordsEdit")
                  	<a class="btn btn-info btn-sm" href="javascript:;" onclick="wordsEdit(#(x.id));" title="修改"><i class="fa fa-lg fa-edit">修改</i></a>
	                #end
	                #permission("/admin/words/wordsDelete")   
                    <a class="btn btn-danger btn-sm" href="javascript:;" onclick="confirmDelete('删除后无法恢复，确定要删除？', '/admin/words/wordsDelete?id=#(x.id)');" title="删除"><i class="fa fa-lg fa-trash">删除</i></a>
                  	#end
                  </td>
                </tr>
                #end
              </tbody>
            </table>
            <div>
               #@adminPaginate(wordsPage.pageNumber, wordsPage.totalPage, "/admin/words?p=") 
            </div>
          </div>
        </div>
       
      </div>
      
  </main>
#end

#define js()
<script type="text/javascript">
$(document).ready(function() {
	initMagicInput(prepareAction);
});

function prepareAction($this, state) {
	return {
		url: state ? "/admin/words/lock" : "/admin/words/unlock",
		data : {
			id: $this.attr("data-id")
		}
	}
}
</script>
#end